import json
import colorsys
#
# with open('websafe.csv','r') as fr:
#     all = fr.read().split('\n')
#
# lenList = len(all) - 1
# print(lenList)
#
# L = []
# for i in range(0, 9):
#     L.append([])
#
# S = []
# for i in range(0, 3):
#     S.append([])
#
# H = []
# for i in range(0, 12):

def hsv2rgb(h,s,v):
    return tuple(round(i * 255) for i in colorsys.hsv_to_rgb(h,s,v))
#
# for i in range(2, lenList, 2):
#     thisStr = all[i].replace(' ',',').replace('\t',',')
#     print(thisStr)
#     thisList = thisStr.split(',')
#
#     cn = thisList[0]
#
#     Lin = int(thisList[6].replace('%',''))
#     Satu = int(thisList[5].replace('%',''))
#     Hue = int(thisList[4].replace('°',''))
#
#     idxLin = Lin / 10
#     L[idxLin].append(cn)

def main():
    # c = colorsys.hsv_to_rgb(359 / 360.0, 1, 1)
    all = []
    ct = 0
    for hue in range(0, 3600, 180):
        all.append([])
        H = hue / 10
        for satu in range(0, 10):
            S = satu
            all[ct].append([])
            for value in range(0, 10):
                V = value
                rgb = hsv2rgb(H / 360, S / 10, V / 10)
                print(H, S, V)
                hexC = '#%02x%02x%02x' % rgb
                all[ct][satu].append(hexC)
        ct += 1

    for i in range(0, len(all)):
        hue = all[i]
        for j in range(0, len(hue)):
            satu = hue[j]
            for k in range(0, len(satu)):
                value = all[i][j][k]

    out = {'colors':all}
    with open('colors20.json','w') as fw:
        fw.write(json.dumps(out, separators=(',',':')))
if __name__ == '__main__':
    main()